package multimedia;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.media.control.RecordControl;

import ui.VadeMecumCameraCanvas;

public class StopRecordThread implements Runnable, CommandListener {

	private VadeMecumCameraCanvas canvas;
	
	public StopRecordThread(VadeMecumCameraCanvas canvas) {
		this.canvas = canvas;
	}
	
	public void run() {
		if (canvas.isRecording()) {
			try {
				RecordControl rc = canvas.getRecordControl();
				rc.stopRecord();
				rc.commit();
				
				//exibe o video e mostra as opcoes
				System.out.println("parou de gravar");

				canvas.setRecording(false);
				canvas.removeCommand(canvas.stopRecording);
				canvas.addCommand(canvas.initRecording);
			} catch (Exception e) {
				canvas.midlet.error(e);
			}
		}
		canvas.midlet.error(new Exception("Is not recording!"));		
	}

	public void commandAction(Command arg0, Displayable arg1) {
				
	}	

}
